<template>
	<view class="page">
		<Navbar iconColor="black">
		</Navbar>
		<!-- 未登录账号时显示 -->
		<view class="userBox-unLogin" v-if="!isLogin">
			<view class="headerImg" @click="toLogin">
				<image src="../../static/images/denglu.png" mode="widthFix"></image>
			</view>
			<view class="toLogin" @click="toLogin">
				<text>立即登录</text>
				<image src="../../static/images/gengduo.png" mode="widthFix"></image>
			</view>
		</view>

		<view class="userBox-Login" v-if="isLogin" @click="toUserDetail">
			<view class="headerImg">
				<image :src="userInfo.profile.avatarUrl" mode="widthFix"></image>
			</view>
			<view class="userInfo">
				<view class="userName">
					<text>{{userInfo.profile.nickname}}</text>
				</view>
				<view class="vip">
					<image :src="userInfo.account.paidFee ? '../../static/images/VIP.png' : '../../static/images/unVip.png'" mode="widthFix"></image>
					<text v-if="!userInfo.account.paidFee">续费</text>
					<image src="../../static/images/gengduo-w.png" mode="widthFix"></image>
				</view>
				<view class="lv">
					<text>Lv.{{userInfo.level}}</text>
				</view>
			</view>
			<view class="jt">
				<image src="../../static/images/gengduo.png" mode="widthFix"></image>
			</view>
		</view>
		<playMusicBar></playMusicBar>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import {
		getUserInfo,
		getUserLevel
	} from '@/api/mine.js'
	import Navbar from '@/components/navbar.vue'
	export default {
		components: {
			Navbar
		},
		data() { 
			return {
			}
		},
		computed: {
			...mapState(['isLogin', 'userInfo'])
		},
		onLoad() {
		},
		created() {
			this.pdLoginStatus() //判断是否登陆
		},
		methods: {
			...mapMutations(['pdLoginStatus']),
			// 跳转登录页
			toLogin() {
				uni.navigateTo({
					url: './login/login'
				})
			},
			// 跳转用户详情
			toUserDetail() {
				uni.navigateTo({
					url: `./userDetail`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.userBox-unLogin {
		width: 690rpx;
		height: 100rpx;
		margin: 30rpx;
		display: flex;
		align-items: center;

		.headerImg {
			width: 100rpx;
			height: 100rpx;

			image {
				width: 100rpx;
			}
		}

		.toLogin {
			height: 100rpx;
			padding-left: 26rpx;
			display: flex;
			align-items: center;

			text {
				font-weight: bolder;
			}

			image {
				width: 25rpx;
				padding-left: 10rpx
			}
		}
	}

	.userBox-Login {
		width: 690rpx;
		height: 100rpx;
		margin: 30rpx;
		display: flex;
		align-items: center;

		.headerImg {
			width: 100rpx;
			height: 100rpx;

			image {
				width: 100rpx;
				border-radius: 50rpx;
			}
		}

		.userInfo {
			width: 540rpx;
			height: 100rpx;
			padding-left: 24rpx;

			.userName {
				font-size: 34rpx;
				font-weight: bolder;
			}

			.vip {
				display: inline-block;
				background-color: #ccc;
				padding: 0 14rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 20rpx;
				font-size: 24rpx;
				color: #fff;

				image {
					&:first-child {
						width: 50rpx;
						margin-right: 6rpx;
					}

					&:last-child {
						width: 16rpx;
						margin-left: 4rpx;
					}
				}
			}

			.lv {
				display: inline-block;
				background-color: #fff;
				margin-left: 10rpx;
				height: 40rpx;
				line-height: 40rpx;
				border-radius: 20rpx;
				padding: 0 16rpx;
				font-size: 26rpx;
			}
		}

		.jt {
			image {
				width: 25rpx;
			}
		}
	}
</style>
